package com.tanhua.server.controller;

import com.tanhua.model.vo.NearUserVo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.RecommendUserVo;
import com.tanhua.model.vo.TodayBestVo;
import com.tanhua.server.service.QuestionService;
import com.tanhua.server.service.TanhuaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "探花相关接口")
@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService tanhuaService;
    @Autowired
    private QuestionService questionService;

    @ApiOperation("今日佳人")
    @GetMapping("todayBest")
    public ResponseEntity todayBest() {
        TodayBestVo vo = tanhuaService.todayBest();
        return ResponseEntity.ok(vo);
    }

    @ApiOperation(("推荐朋友"))
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserVo recommendUserVo) {
        PageResult<TodayBestVo> pageResult =  tanhuaService.recommendation(recommendUserVo);
        return ResponseEntity.ok(pageResult);
    }

    @ApiOperation("查看佳人信息")
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable Long id) {
        TodayBestVo vo = tanhuaService.personalInfo(id);
        return ResponseEntity.ok(vo);
    }

    @ApiOperation("查询陌生人问题")
    @GetMapping("/strangerQuestions")
    public ResponseEntity queryStrangerQuestions(Long userId) {
        String question = tanhuaService.queryQuestions(userId);
        return ResponseEntity.ok(question);
    }

    @ApiOperation("回复陌生人问题")
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map<String,String> params) {
        tanhuaService.replyStrangerQuestions(params);
        return ResponseEntity.ok(null);
    }

    @ApiOperation("探花-推荐好友")
    @GetMapping("/cards")
    public ResponseEntity cards() {
        List<TodayBestVo> todayBestVoList = tanhuaService.cards();
        return ResponseEntity.ok(todayBestVoList);
    }

    @ApiOperation("探花-右滑")
    @GetMapping("/{userId}/love")
    public ResponseEntity love(@PathVariable Long userId) {
        tanhuaService.love(userId, true);
        return ResponseEntity.ok(null);
    }

    @ApiOperation("探花-左滑")
    @GetMapping("/{userId}/unlove")
    public ResponseEntity unlove(@PathVariable Long userId) {
        tanhuaService.love(userId, false);
        return ResponseEntity.ok(null);
    }

    @ApiOperation("搜索附近")
    @GetMapping("/search")
    public ResponseEntity searchNearBy(String gender, Long distance) {
        List<NearUserVo> vos = tanhuaService.searchNearBy(gender, distance);
        return ResponseEntity.ok(vos);
    }
}
